home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / RAND / UNSPLIT / BM214SRC.ZIP / 68030 / DOOM.S < prev    next >
Encoding:
Text File  |  1996-07-02  |  18.8 KB  |  723 lines

  1. *=======================================================*
  2. *    Falcon030 Doom project (Bad Mood) v2.13 alpha    *
  3. *=======================================================*
  4. *    Main core: latest update 25/03/96        *
  5. *=======================================================*
  6.  
  7.     OPT        P=68030
  8.     OPT        W-
  9.  
  10. *-------------------------------------------------------*
  11. *    Conditional options                *
  12. *-------------------------------------------------------*
  13.  
  14. ;frsb
  15. ;test                    ; enable for pre-defined WAD (debug).
  16. ;debuggable                ; enable for 'soft' safe interrupts.
  17. enable_timing                ; enable for timing information.
  18.  
  19. *-------------------------------------------------------*
  20. *    Compatibility settings                *
  21. *-------------------------------------------------------*
  22.  
  23. ;compat_level        =    0    ; I don't think so...
  24. ;compat_level        =    1    ; 16Mhz base Falcons.
  25. ;compat_level        =    2    ; Accelerated Falcons.
  26. ;compat_level        =    3    ; Even more accelerated Falcons.
  27. ;compat_level        =    4    ; MC68040 & super-accelerated Falcons.
  28. compat_level        =    99    ; 100% ensured legal DSP handshaking.
  29.  
  30. *-------------------------------------------------------*
  31. *    Display settings                *
  32. *-------------------------------------------------------*
  33.  
  34. ;default_width        =    320    ; default width
  35. ;default_height        =    200    ; vertical normal mode (status bar)
  36. ;expanded_height        =    240    ; vertical fullscreen mode
  37.  
  38. ;base_aspect        =    200    ; base reference (unadjusted) ratio.
  39. ;vga_aspect        =    240    ; 240-line aspect ratio (VGA).
  40. ;rgb_aspect        =    200    ; 200-line aspect ratio (PAL).
  41.  
  42. default_width        =    320    ; default width
  43. default_height        =    168    ; vertical normal mode (status bar)
  44. expanded_height        =    200    ; vertical fullscreen mode
  45.  
  46. base_aspect        =    200    ; base reference (unadjusted) ratio.
  47. vga_aspect        =    200    ; 240-line aspect ratio (VGA).
  48. rgb_aspect        =    168    ; 200-line aspect ratio (PAL).
  49.  
  50. *-------------------------------------------------------*
  51.  
  52. base_red        =    255
  53. base_green        =    255
  54. base_blue        =    255
  55.  
  56. *-------------------------------------------------------*
  57. *    Keycodes for control & player movement        *
  58. *-------------------------------------------------------*
  59. *    These should go away once the event-based    *
  60. *    keyboard routines are ready.            *
  61. *-------------------------------------------------------*
  62.  
  63. rise_key        =    2
  64. drop_key        =    3
  65. hres_key        =    4
  66. vres_key        =    5
  67. text_key        =    28
  68.  
  69. rgb_key            =    19
  70. vga_key            =    47
  71. full_key        =    33
  72.  
  73. quit_key        =    1    ; 'ESC' key
  74. map_key            =    15    ; 'TAB' key
  75.  
  76. minus_key        =    12    ;
  77. plus_key        =    13    ;
  78.  
  79. left_key        =    $4b    ; left arrow
  80. right_key        =    $4d    ; right arrow
  81. forward_key        =    $48    ; up arrow
  82. back_key        =    $50    ; down arrow
  83. alt_key            =    $38    ; 'ALT' key
  84.  
  85. lshift_key        =    42
  86. rshift_key        =    54
  87.  
  88. *-------------------------------------------------------*
  89. *    Main program includes                *
  90. *-------------------------------------------------------*
  91.  
  92.     include        include\header.s
  93.     include        include\macros.s
  94.     include        include\video.s
  95. ;    include        cache.s
  96.  
  97. *-------------------------------------------------------*
  98. *    DSP core includes                *
  99. *-------------------------------------------------------*
  100.  
  101.     include        include\dspconst.s
  102.     
  103. *-------------------------------------------------------*
  104. *    Mark TEXT, DATA & BSS reference sections    *
  105. *-------------------------------------------------------*
  106.     bss
  107. *-------------------------------------------------------*
  108. bss_start:
  109. *-------------------------------------------------------*
  110.     data
  111. *-------------------------------------------------------*
  112. data_start:
  113. *-------------------------------------------------------*
  114.     text
  115. *-------------------------------------------------------*
  116. text_start:
  117. *-------------------------------------------------------*
  118. *    Path for pre-defined WAD            *    
  119. *-------------------------------------------------------*
  120.     bra        Doom
  121. *-------------------------------------------------------*
  122.  
  123. default_path:        ;dc.b    'l:\wads\doom.wad e4m8'
  124.             dc.b    'l:\wads\doom.wad e1m1'
  125.             ;dc.b    'l:\wads\doom.wad e1m6'
  126.             ;dc.b    'l:\wads\doom2.wad map01'
  127.             ;dc.b    'l:\wads\heretic1.wad e1m4'
  128.  
  129.             ;dc.b    '-i l:\wads\doom.wad -p l:\wads\alpha.wad'
  130.  
  131.             ;dc.b    '-i l:\wads\doom2.wad -p l:\wads\scorpion.wad -w map01'
  132.             ;dc.b    '-i l:\wads\doom.wad -p l:\wads\uac_dead.wad -w e1m8'
  133.             ;dc.b    '-i l:\wads\doom2.wad -w map01'
  134.             ;dc.b    '-i l:\wads\doom2.wad -w map11'
  135.             ;dc.b    '-i l:\wads\doom.wad -w e1m1'
  136.  
  137.             dc.b    0
  138.             ds.b    255
  139.  
  140. iwad_path:        ds.b    256
  141. pwad_path:        ds.b    256
  142. levelmarker:        ds.b    8
  143.  
  144. *-------------------------------------------------------*
  145. *    Program starts here                *    
  146. *-------------------------------------------------------*
  147.     txtlong
  148. *-------------------------------------------------------*
  149.  
  150. Doom:    move.l        4(sp),a5
  151.     lea        128(a5),a4    ; command string
  152.     move.l        a4,cli
  153.     move.l        12(a5),d0    ; text segment
  154.     add.l        20(a5),d0    ; data segment
  155.     add.l        28(a5),d0    ; bss segment
  156.     add.l        #$100,d0    ; base page
  157.     move.l        d0,-(sp)
  158.     move.l        a5,-(sp)
  159.     clr.w        -(sp)
  160.     move.w        #$4a,-(sp)
  161.     trap        #1        ; mshrink
  162.     lea        12(sp),sp
  163. *-------------------------------------------------------*
  164. *    Hide mouse                    *
  165. *-------------------------------------------------------*
  166.     dc.w        $A00A
  167. *-------------------------------------------------------*
  168. *    Commandline module                *
  169. *-------------------------------------------------------*
  170.     bsr        parse_cli
  171. *-------------------------------------------------------*
  172. *    Flush out BSS                    *
  173. *-------------------------------------------------------*
  174.     lea        bss_start,a0
  175.     move.l        #(bss_end-bss_start)/4,d0
  176.     moveq        #0,d1
  177. .clr:    move.l        d1,(a0)+
  178.     subq.l        #1,d0
  179.     bne.s        .clr
  180. *-------------------------------------------------------*
  181. *    Allocate ST-RAM space for 3 screenbuffers    *
  182. *-------------------------------------------------------*
  183.     bsr        allocate_screens
  184. *-------------------------------------------------------*
  185. *    Initialise memory manager            *
  186. *-------------------------------------------------------*
  187.     bsr        init_block_manager
  188. *-------------------------------------------------------*
  189. *    Flush keyboard buffer                *
  190. *-------------------------------------------------------*
  191.     bsr        empty_buffer
  192. *-------------------------------------------------------*
  193. *    Parse Doom WAD files                *
  194. *-------------------------------------------------------*
  195.     move.l        #hash_space,hash_array
  196.     bsr        parse_iwad
  197.     bsr        parse_pwad
  198.     Cconws        #ascii_entriesdone
  199. *-------------------------------------------------------*
  200. *    Integrate PWAD into main IWAD directory        *
  201. *-------------------------------------------------------*
  202.     bsr        integrate_wads
  203. *-------------------------------------------------------*
  204. *    Load level resources                *
  205. *-------------------------------------------------------*
  206.     bsr        load_leveldata
  207. *-------------------------------------------------------*
  208. *    Initialise textures & colourmaps        *
  209. *-------------------------------------------------------*
  210.     bsr        init_textures
  211.     bsr        init_cache
  212.     bsr        init_colours
  213.     bsr        thrash_level
  214.     Cconws        #ascii_replacedone
  215. *-------------------------------------------------------*
  216. *    Calculate wall lengths                *
  217. *-------------------------------------------------------*
  218.     bsr        measure_linedefs
  219. *-------------------------------------------------------*
  220. *    Wad parsing complete - close wadfile & pause    *
  221. *-------------------------------------------------------*
  222.     bsr        close_wad
  223.     Crawcin
  224. *-------------------------------------------------------*
  225. *    Switch to supervisor mode            *
  226. *-------------------------------------------------------*
  227.     pea        0.w
  228.     push.w        #32
  229.     trap        #1
  230.     push.l        d0
  231. *-------------------------------------------------------*
  232. *    Setup new truecolour video mode            *
  233. *-------------------------------------------------------*
  234.     bsr        select_video
  235. *-------------------------------------------------------*
  236. *    Kickstart DSP Doom Core                *
  237. *-------------------------------------------------------*
  238.     bsr        kickstart_doomcore
  239. *-------------------------------------------------------*
  240. *    Select initial window size & prepare lists    *
  241. *-------------------------------------------------------*
  242.     move.w        #window_max,window_size
  243.     bsr        select_window
  244. *-------------------------------------------------------*
  245. *    Set up global display structure            *
  246. *-------------------------------------------------------*
  247.     bsr        init_displaystruct
  248. *-------------------------------------------------------*
  249. *    Enable VBI & timing interrupts            *
  250. *-------------------------------------------------------*
  251.     bsr        init_timing
  252. *-------------------------------------------------------*
  253. *    Replace keyboard handler            *
  254. *-------------------------------------------------------*
  255.     bsr        initialise_ikbd
  256. *-------------------------------------------------------*
  257.     bsr        open_wad
  258. *-------------------------------------------------------*
  259. *    Main program loop                *
  260. *-------------------------------------------------------*
  261. game_loop:
  262. *-------------------------------------------------------*
  263. *    Read keyboard (debug mode only)            *
  264. *-------------------------------------------------------*
  265.     ifd        debuggable
  266.     bsr        read_key
  267.     endc
  268. *-------------------------------------------------------*
  269. *    Move player                     *
  270. *-------------------------------------------------------*
  271.     bsr        player_control
  272. *-------------------------------------------------------*
  273. *    Get player direction                *    
  274. *-------------------------------------------------------*
  275.     bsr        triangulate
  276. *-------------------------------------------------------*
  277. *    Display 3D environment                *
  278. *-------------------------------------------------------*
  279.     bsr        display_engine
  280. *-------------------------------------------------------*
  281. *    Display level map                *    
  282. *-------------------------------------------------------*
  283.     bsr        display_map
  284. *-------------------------------------------------------*
  285. *    Display framerate in corner of screen        *
  286. *-------------------------------------------------------*
  287.     ifd        enable_timing
  288.     bsr        timing
  289.     endc
  290. *-------------------------------------------------------*
  291. *    Double-buffered display                *
  292. *-------------------------------------------------------*
  293.     vsync
  294.     bsr        adjust_scanlines
  295. *-------------------------------------------------------*
  296.     ifd        frsb
  297. *-------------------------------------------------------*
  298.     move.l        ScreenLog,a0
  299.     move.l        ScreenPhy,a1
  300.     move.w        #320/2,d0
  301.     move.w        width,d1
  302.     lsr.w        d1
  303.     sub.w        d1,d0
  304.     lsr.w        #3,d0        ; d0 = dphrase start
  305.     move.w        d0,d6
  306.     lsl.w        #3,d6
  307.     add.w        width,d6
  308.     addq.w        #8-1,d6
  309.     lsr.w        #3,d6        ; d6 = qphrase end
  310.     sub.w        d0,d6        ; qphrase length
  311.     lsl.w        #3+1,d0
  312.     add.w        d0,a0
  313.     add.w        d0,a1
  314.     move.w        height,d7
  315.     move.w        scrwidth,a2
  316.     add.l        a2,a2
  317.     move.w        d6,d5
  318.     lsl.w        #3+1,d5
  319.     sub.w        d5,a2
  320.     subq.w        #1,d6
  321.     subq.w        #1,d7
  322. .yl:    move.w        d6,d0
  323. .xl:    move16        (a0)+,(a1)+
  324.     dbra        d0,.xl
  325.     add.l        a2,a0
  326.     add.l        a2,a1
  327.     dbra        d7,.yl
  328. *-------------------------------------------------------*
  329.     elseif
  330. *-------------------------------------------------------*
  331.     doublebuffer
  332. *-------------------------------------------------------*
  333.     endc
  334. *-------------------------------------------------------*
  335. *    Check for exit key                *
  336. *-------------------------------------------------------*
  337.     tst.b        program_quit
  338.     beq        game_loop
  339.  
  340. *-------------------------------------------------------*
  341. *    Program end - restore parameters & exit        *
  342. *-------------------------------------------------------*
  343. game_exit:
  344. *-------------------------------------------------------*
  345. *    Restore system                    *
  346. *-------------------------------------------------------*
  347.     bsr        close_wad
  348.     bsr        remove_ikbd
  349.     bsr        reset_timing
  350.     bsr        empty_buffer
  351.     bsr        restore_video
  352. *-------------------------------------------------------*
  353. *    Return to user mode                *
  354. *-------------------------------------------------------*
  355.     move.w        #32,-(sp)
  356.     trap        #1
  357.     lea        10(sp),sp
  358. *-------------------------------------------------------*
  359. *    Exit program                    *
  360. *-------------------------------------------------------*
  361. safe_quit:
  362. *-------------------------------------------------------*
  363. *    Unhide the mouse                *
  364. *-------------------------------------------------------*
  365.     dc.w        $A009
  366. *-------------------------------------------------------*
  367. *    Terminate program                *
  368. *-------------------------------------------------------*
  369.     clr.w        -(sp)
  370.     trap        #1
  371.  
  372. *-------------------------------------------------------*
  373. *    Player control module with turning & movement    *
  374. *-------------------------------------------------------*
  375.     txtlong
  376. *-------------------------------------------------------*
  377. player_control:
  378. *-------------------------------------------------------*
  379.     lea        key_buffer,a6
  380.  
  381.     tst.b        rgb_key(a6)
  382.     beq.s        .nrgb
  383.     move.w        #rgb_aspect,aspect_ratio
  384.     bsr        select_window
  385. .nrgb:
  386.     tst.b        vga_key(a6)
  387.     beq.s        .nvga
  388.     move.w        #vga_aspect,aspect_ratio
  389.     bsr        select_window
  390. .nvga:
  391.     tst.b        full_key(a6)
  392.     beq.s        .nf
  393.     move.w        #expanded_height,viewport_height
  394.     not.b        fullscreen
  395.     bne.s        .nf1
  396.     move.w        #default_height,viewport_height
  397. .nf1:    bsr        select_window
  398. .nf:
  399.     
  400. ;    tst.b        text_key(a6)
  401. ;    beq.s        .ntx
  402. ;    bsr        texture_loop
  403. ;.ntx:
  404.     tst.b        hres_key(a6)
  405.     beq.s        .ndh
  406.     not.b        halfrows
  407.     bsr        select_window
  408. .ndh:
  409.     tst.b        vres_key(a6)
  410.     beq.s        .ndv
  411.     not.b        halflines
  412.     bsr        select_window
  413. .ndv:
  414.  
  415.  
  416.     tst.b        plus_key(a6)
  417.     beq.s        .nwp
  418.     add.w        #32,window_size
  419.     bsr        select_window
  420. .nwp:    tst.b        minus_key(a6)
  421.     beq.s        .nwm
  422.     sub.w        #32,window_size
  423.     bsr        select_window
  424. .nwm:    tst.b        quit_key(a6)
  425.     beq.s        .nox
  426.     st        program_quit
  427. .nox:    tst.b        map_key(a6)
  428.     beq.s        .nmk
  429.     not.b        map_enabled
  430. .wlp:    tst.b        map_key(a6)
  431.     bne.s        .wlp
  432. .nmk:    rts
  433.  
  434. player_movement:
  435.     lea        key_buffer,a6
  436.  
  437.     move.l        #rotate_speed,d5
  438.     move.l        #slide_speed,d6
  439.     move.l        #walk_speed,d7
  440.  
  441.     tst.b        lshift_key(a6)
  442.     bne.s        .ys
  443.     tst.b        rshift_key(a6)
  444.     beq.s        .ns
  445. .ys:    add.l        d5,d5
  446.     add.l        d6,d6
  447.     add.l        d7,d7
  448. .ns:
  449.  
  450.     tst.b        rise_key(a6)
  451.     beq.s        .nr
  452.     addq.w        #4,pho
  453. .nr:    tst.b        drop_key(a6)
  454.     beq.s        .nd
  455.     subq.w        #4,pho
  456. .nd:
  457.     tst.b        left_key(a6)
  458.     beq.s        .not_left
  459.     tst.b        alt_key(a6)
  460.     bne.s        .slide_left
  461.     add.l        d5,pangle
  462.     bra.s        .not_left
  463. .slide_left:
  464.     add.l        d6,right_speed
  465. .not_left:
  466.     tst.b        right_key(a6)
  467.     beq.s        .not_right
  468.     tst.b        alt_key(a6)
  469.     bne.s        .slide_right
  470.     sub.l        d5,pangle
  471.     bra.s        .not_right
  472. .slide_right:
  473.     sub.l        d6,right_speed
  474. .not_right:
  475.     tst.b        forward_key(a6)
  476.     beq.s        .not_forward
  477.     add.l        d7,front_speed
  478. .not_forward:
  479.     tst.b        back_key(a6)
  480.     beq.s        .not_back
  481.     sub.l        d7,front_speed
  482. .not_back:
  483.     move.w        mouse_dy,d0
  484.     beq.s        .no_mouse_y
  485.     clr.w        mouse_dy
  486.     ext.l        d0
  487.     muls.l        #walk_speed,d0
  488.     asr.l        d0
  489.     move.l        d0,d1
  490.     asr.l        #1,d1
  491.     sub.l        d1,d0
  492.     sub.l        d0,front_speed    
  493. .no_mouse_y:
  494.     move.w        mouse_dx,d0
  495.     beq.s        .no_mouse_x
  496.     clr.w        mouse_dx
  497.     ext.l        d0
  498.     cmp.b        #1,buttons
  499.     bne.s        .rotate
  500.     muls.l        #slide_speed,d0
  501.     asr.l        d0
  502.     move.l        d0,d1
  503.     asr.l        #1,d1
  504.     sub.l        d1,d0
  505.     sub.l        d0,right_speed    
  506.     bra.s        .no_mouse_x
  507. .rotate:
  508.     muls.l        #rotate_speed,d0
  509.     asr.l        #3,d0
  510.     move.l        d0,d1
  511.     asr.l        #2,d1
  512.     sub.l        d1,d0
  513.     sub.l        d0,pangle
  514. .no_mouse_x:
  515.     move.l        right_speed,d0
  516.     beq.s        .no_right
  517.     move.w        #right_angle,d1
  518.     bsr        move_player
  519.     lea        right_speed,a0
  520.     bsr        decay_speed
  521. .no_right:
  522.     move.l        front_speed,d0
  523.     beq.s        .no_front
  524.     move.w        #front_angle,d1
  525.     bsr        move_player
  526.  
  527.     move.l        front_speed,d0
  528.     add.l        bob_shift,d0
  529.     move.l        d0,bob_shift
  530.  
  531.     move.l        d0,d1
  532.     lsl.l        #4,d0
  533.     lsl.l        #3,d1
  534.     add.l        d1,d0
  535.     lsr.l        d1
  536.     add.l        d1,d0
  537.  
  538.     swap        d0
  539.     and.w        #sinres-1,d0
  540.     move.w        (sine.l,d0.w*2),d0
  541.     asr.w        #8,d0
  542.     asr.w        #4,d0
  543.     move.w        d0,pho
  544.  
  545.     lea        front_speed,a0
  546.     bsr        decay_speed
  547. .no_front:
  548.     rts
  549.  
  550. decay_speed:
  551.     move.l        (a0),d0
  552.     bmi.s        .neg    
  553.     move.l        d0,d1
  554.     lsr.l        #2,d0
  555.     sub.l        d0,d1
  556.     and.l        #-128,d1
  557.     move.l        d1,(a0)
  558.     rts
  559. .neg:    neg.l        d0
  560.     move.l        d0,d1
  561.     lsr.l        #2,d0
  562.     sub.l        d0,d1
  563.     and.l        #-128,d1
  564.     neg.l        d1
  565.     move.l        d1,(a0)
  566.     rts
  567.  
  568.  
  569. bob_shift:    ds.l    1
  570.  
  571.     rept        0
  572.  
  573.     tst.b        left_key(a6)
  574.     beq.s        not_left
  575.     tst.b        alt_key(a6)
  576.     bne.s        move_left
  577.     add.w        #turn_speed,pangle
  578.     bra.s        not_left
  579. move_left:
  580.     move.w        #$4000,d1
  581.     move.w        #player_speed,d0
  582.     bsr        move_player
  583. not_left:
  584.     tst.b        right_key(a6)
  585.     beq.s        not_right
  586.     tst.b        alt_key(a6)
  587.     bne.s        move_right
  588.     sub.w        #turn_speed,pangle
  589.     bra.s        not_right
  590. move_right:
  591.     move.w        #$4000,d1
  592.     move.w        #-player_speed,d0
  593.     bsr        move_player
  594. not_right:
  595.     tst.b        forward_key(a6)
  596.     beq.s        not_forward
  597.     move.w        #player_speed,d0
  598.     moveq        #0,d1
  599.     bsr        move_player
  600. not_forward:
  601.     tst.b        back_key(a6)
  602.     beq.s        not_back
  603.     move.w        #-player_speed,d0
  604.     moveq        #0,d1
  605.     bsr        move_player
  606. not_back:
  607.     move.w        mouse_dy,d0
  608.     beq        no_mouse_y
  609.     neg.w        d0
  610.     moveq        #0,d1
  611.     bsr        move_player
  612.     clr.w        mouse_dy
  613. no_mouse_y:
  614.     move.w        mouse_dx,d0
  615.     beq        no_mouse_x
  616.     cmp.b        #1,buttons
  617.     bne.s        rotate
  618.     neg.w        d0
  619.     move.w        #$4000,d1
  620.     bsr        move_player
  621.     bra.s        no_mouse_x
  622. rotate:
  623.     move.w        mouse_dx,d0
  624.     asl.w        #5,d0
  625.     sub.w        d0,pangle
  626. no_mouse_x:
  627.     clr.w        mouse_dx
  628.  
  629.     endr
  630.     
  631.     rts
  632.  
  633. *-------------------------------------------------------*
  634. * Generic movement routine -    d0 = distance        *
  635. *                d1 = angle offset    *
  636. *-------------------------------------------------------*
  637.     txtlong
  638. *-------------------------------------------------------*
  639. move_player:
  640. *-------------------------------------------------------*
  641.     lsl.l        #2,d0
  642.     move.l        d0,d2            ; save distance for later 
  643.     add.w        pangle,d1
  644.     lsr.w        #(16-12),d1
  645.     move.w        (sine.l,d1.w*2),d3
  646.     ext.l        d3
  647.     muls.l        d3,d3:d0
  648.     move.w        d3,d0
  649.     swap        d0
  650.     add.w        #sinres/4,d1
  651.     and.w        #sinres-1,d1
  652.     move.w        (sine.l,d1.w*2),d3
  653.     ext.l        d3
  654.     muls.l        d3,d3:d2
  655.     move.w        d3,d2
  656.     swap        d2
  657.     add.l        d0,py
  658.     add.l        d2,px
  659.     rts
  660.  
  661. *-------------------------------------------------------*
  662. *    Convert rotational angle into a vector        *
  663. *-------------------------------------------------------*
  664.     txtlong
  665. *-------------------------------------------------------*
  666. triangulate:
  667. *-------------------------------------------------------*
  668.     move.w        pangle,d0
  669.     andi.l        #$ffff,d0    
  670.     neg.l        d0
  671.     lsr.w        #(16-12),d0
  672.     lea        sine,a0
  673.     move.w        (a0,d0.w*2),d1
  674.     add.w        #sinres/4,d0
  675.     and.w        #sinres-1,d0
  676.     ext.l        d1
  677.     lsl.l        #2,d1
  678.     move.l        d1,sinpangle
  679.     move.w        (a0,d0.w*2),d1
  680.     ext.l        d1
  681.     lsl.l        #2,d1
  682.     move.l        d1,cospangle
  683.     rts
  684.     
  685. *-------------------------------------------------------*
  686. *    Program modules                    *
  687. *-------------------------------------------------------*
  688.  
  689.     include        io.s
  690.     include        levelmap.s
  691.     include        keyboard.s
  692.     include        screen.s
  693.     include        textures.s
  694.     include        engine.s
  695.     include        memory.s
  696.     include        cache.s
  697.  
  698. *-------------------------------------------------------*
  699.             bsslong
  700. *-------------------------------------------------------*
  701.  
  702. cli:            ds.l    1        ; command line pointer
  703.  
  704. px:            ds.l    1        ; player-x
  705. py:            ds.l    1        ; player-y
  706. pho:            ds.w    1        ; player height offset (for flying)
  707. pangle:            ds.l    1        ; player direction
  708. cospangle:        ds.l    1        ; Cos[d]
  709. sinpangle:        ds.l    1        ; Sin[d]
  710.  
  711. right_speed:        ds.l    1
  712. front_speed:        ds.l    1
  713.  
  714. program_quit:        ds.b    1        ; exit flag
  715.  
  716. string_space:        ds.b    256        ; general string space
  717.  
  718. *-------------------------------------------------------*
  719.             bsslong
  720. *-------------------------------------------------------*
  721. bss_end:
  722. *-------------------------------------------------------*
  723.